<?php
/*
Galaxy
Author:McFog
*/
defined('IN GALAXY') or exit('McFog');

class model_form {
	var $method='POST', $target='';
	var $fields=array();
	private $hash='';
	function __get($name) {
		switch($name) {
			case 'formhash':
				if($this->hash!=='') {
					return $this->hash;
				} else {
					$g = galaxy::getInstance();
					$this->hash = md5( serialize($this).$g->galx_uid.
						$g->bbinfo['sitesalt'].substr($g->timestamp,0,-6).
						$_ENV['onlineip'] );
					return $this->hash;
				}
		}
		galaxy::debug('Undefined property via __get()');
		return null;
	}
	function checkFormhash($ret = false, $fieldname = 'formhash') {
		if($_POST[$fieldname] != $this->formhash) {
			if($ret) return false;
			galaxy::halt('Incorrect formhash');
		}
		if($ret) return true;
	}
}

?>